package com.snowleopard.findpeople.dao.publish;

import org.springframework.stereotype.Repository;
import org.springside.modules.orm.Page;

import com.snowleopard.common.base.BaseDao;
import com.snowleopard.findpeople.entity.publish.InfoPublish;

@Repository
public class InfoPublishDao extends BaseDao<InfoPublish, String> {

    public Page<InfoPublish> findPage(Page<InfoPublish> page, InfoPublish infoPublish) {

        if (infoPublish.getArea() != null) {
            eq("area.id", infoPublish.getArea().getId());
            eq("trade.id", infoPublish.getTrade().getId());
        }

        eq("type", infoPublish.getType());
        like("title", infoPublish.getTitle());
        like("content", infoPublish.getContent());
        like("modifiedBy", infoPublish.getModifiedBy());

        return findPage(page);
    }
}
